<?php
    session_start();
    if (!isset($_SESSION['emp_id'])) {
        echo "not logged in";
    }
    require_once ('connection.inc.php');

/* ====================================
 * Check if a product exists after scan
 */
    $product_barcode = $_GET['barcode'];
    $shop_id = SHOP_ID;
    
    $sql = "SELECT product_id FROM af1_products WHERE product_barcode = $product_barcode AND shop_id = $shop_id";
    $result = mysqli_query($connection, $sql);
    $num_rows = mysqli_num_rows($result);
    if ($num_rows == 0) {
        echo "not found";
    }
    else if ($num_rows == 1) {
        echo "found 1";
    }
    else {
        echo "duplicate found";
        //File a report or something here
    }